package com.zhangfei.stream;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * skip(n) —— 跳过元素，返回一个扔掉了前 n 个元素的流。若流中元素不足 n 个，则返回一个空流。与 limit(n) 互补
 */
public class SkipTest {
    public static void main(String[] args) {
        //初始化学生数据并转成list
        List<Student> students = Arrays.asList(
                new Student(1, "张三", 25),
                new Student(3, "李四", 32),
                new Student(4, "王五", 40),
                new Student(5, "赵六", 29));
        skipStudent(students);
    }

    public static void skipStudent(List<Student> students) {
        List<Student> studentList = students.stream()
                .skip(2)
                .collect(Collectors.toList());
        System.out.println(studentList);
    }
}
